package us.wili.dev.client.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import us.wili.dev.client.dao.ClientHotMapper;
import us.wili.dev.client.model.rsp.GoodsRsp;
import us.wili.dev.client.service.ClientGoodsService;
import us.wili.dev.client.service.ClientHotService;
import us.wili.dev.model.entity.Goods;
import us.wili.dev.model.entity.Hot;
import us.wili.dev.model.example.HotExample;
import us.wili.dev.service.impl.BaseHotServiceImpl;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ClientHotServiceImpl extends BaseHotServiceImpl implements ClientHotService {
    @Resource
    private ClientHotMapper clientHotMapper;

    @Autowired
    private ClientGoodsService clientGoodsService;

    @Override
    public List<GoodsRsp> hot() {
        List<Hot> hots = searHot();
        List<GoodsRsp> rsps = new ArrayList<>();
        for (Hot hot : hots) {
            GoodsRsp rsp = clientGoodsService.hot(hot);
            rsps.add(rsp);
        }
        return rsps;
    }

    public List<Hot> searHot() {
        HotExample example = new HotExample();
        example.createCriteria();
        return clientHotMapper.selectByExample(example);
    }
}
